//
//  DHEmailChangeController.m
//  精品酒店
//
//  Created by DIANGHONG on 2018/5/16.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "DHEmailChangeController.h"

@interface DHEmailChangeController ()
@property (weak, nonatomic) IBOutlet UITextField *emailTxtField;

@end

@implementation DHEmailChangeController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableFooterView = [[UIView alloc] init];
}
#pragma mark: - touchesBegan
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:true];
}
#pragma mark: - 发送验证邮箱按钮监听
- (IBAction)postEmailConfirm:(UIButton *)sender
{
    if (!self.emailTxtField.hasText) {[SVProgressHUD showInfoWithStatus:@"请输入邮箱地址"];return;}
    
    NSString *url = [NSString stringWithFormat:@"%@%@",REMOTEURL,@"index.php?act=member_security&op=send_bind_email"];
    NSMutableDictionary *dictM = [NSMutableDictionary dictionary];
    dictM[@"key"] = DHNetworkManager.shareManager.userAccount.key;
    dictM[@"email"] = self.emailTxtField.text;
    
    [DHNetworkManager.shareManager requestWithMethod:MethodPost
                                           UrlString:url
                                              params:dictM.copy
                                          completion:^(id json, BOOL isSuccess)
    {
        if (!isSuccess) {
            [SVProgressHUD showInfoWithStatus:@"请检查网络"];
            return ;
        }
        if ([json[@"datas"] isEqualToString:@"1"]) {
            [SVProgressHUD showSuccessWithStatus:@"验证邮箱，已经发送至您的邮箱"];
            [self.navigationController popToViewController:self.navigationController.childViewControllers[1] animated:true];
        }
        
        if (json[@"error"]) {
            [SVProgressHUD showInfoWithStatus:json[@"error"]];
            
        }
        
  
      
    }];
    
}

@end
